package com.ap.core.validation.message.rules;

import com.ap.core.message.managepayment.info.ConfirmPaymentRequestMessageInfo;
import com.ap.core.validation.message.info.MessageValidationInfo;
import com.ap.core.validation.message.info.RTPOriginalInfoForConfirmPayment;
import com.ap.core.validation.rules.AbstractValidationRule;
import org.joda.time.LocalDateTime;

/**
 * User: Ranjit.Singh
 * Check if original confirm payment was expired
 */
public class TV0003RepeatedConfirmPaymentRule extends AbstractValidationRule<MessageValidationInfo<ConfirmPaymentRequestMessageInfo, RTPOriginalInfoForConfirmPayment>> {


    @Override
    public boolean validate(MessageValidationInfo<ConfirmPaymentRequestMessageInfo, RTPOriginalInfoForConfirmPayment> infoObject) {
        boolean pass =true;
        final LocalDateTime confirmationExpiryTimeStmp =  infoObject.getOriginalInfo().getConfirmationExpiryTimeStmp();
        if(null != confirmationExpiryTimeStmp && confirmationExpiryTimeStmp.isBefore(infoObject.getOriginalInfo().getConfirmationTimeStmp())){
            return false;
        }
        return pass;
    }

}
